<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>

<style>	

</style>

<div class="weui-cells"
	style="margin-bottom: 0px; padding-top: 0px; margin-top: 0px">
	<c:if test="${empty incomeDetails}">
		<div class="weui-panel_body" style="text-align: center;">
			<img alt="" src="<c:url value='/images/we/personCenter/null.png' />">
			<p style="margin: 5px 20px; color: #afafaf">空空如也...</p>
		</div>
	</c:if>
	<c:forEach var="incomeDetail" items="${incomeDetails}">
		<div class="weui-cell businessDetail"
			style="border-bottom: 1px solid #e5e5e5">
			<div class="weui-cell__bd">
				<p>
					<t:provider packageName="acc" enumClassName="IncomeState"
						value="${incomeDetail.incomeState}" />
				</p>
				<span style="font-size: 12px; color: #c4b2b2;"> <fmt:formatDate
						value="${incomeDetail.time}" pattern="yyyy-MM-dd HH:mm:ss" />
				</span>
			</div>
			<div class="weui-cell__ft">
				<input type="hidden" class="state" value="${incomeDetail.state}" />
				<p style="font-size: 16px">
					<c:if test="${incomeDetail.state == 'income'}">
						<span id="plusMinus"> +<span class="incomeMoney">${incomeDetail.incomeAccount}</span>元
						</span>
					</c:if>
					<c:if test="${incomeDetail.state == 'pay'}">
						<span id="plusMinus"> -<span class="incomeMoney">${incomeDetail.incomeAccount}</span>元
						</span>
					</c:if>

				</p>
			</div>
		</div>

		<input type="hidden" class="commercial"
			value="${incomeDetail.commercialInsurance}" />

		<c:if test="${incomeDetail.commercialInsurance > 0}">
			<div class="business" hidden style="border-bottom: 1px solid #e5e5e5">
				<div class="weui-cell">
					<div class="weui-cell__bd" style="color: #afafaf;">
						<label for="" class="weui-label">订单总保费</label>
					</div>
					<div class="weui-cell__ft">
						<span>${incomeDetail.commercialInsurance}</span>元
					</div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__bd" style="color: #afafaf;">
						<label for="" class="weui-label">订单奖金比例</label>
					</div>
					<div class="weui-cell__ft">
						<span style="padding-right: 10px">×</span><span>${incomeDetail.percent}</span>
					</div>
				</div>
				<div class="weui-cell" style="color: red;">
					<div class="weui-cell__bd" style="color: #afafaf;">
						<label for="" class="weui-label">您的奖励金额</label>
					</div>
					<div class="weui-cell__ft">
						<span class="incomeMoney">${incomeDetail.commercialInsurance * incomeDetail.percent}</span>元
					</div>
				</div>
				<a class="weui-cell"
					href="<c:url value='/wechat/acc/myWealth/income?id=${incomeDetail.id}' />">
					<span style="width: 100%; text-align: center; color: blue">查看订单详情</span>
				</a>
			</div>
		</c:if>
		<input type="hidden" class="incomeId" value="${incomeDetail.id}" />
	</c:forEach>
</div>

<div class="weui-cells " style="margin-top: 4em">
	<div class="weui-cell weui-tabbar">
		<div class="weui-cell__bd " style="font-size: 16px">
			<p style="font-size: 16px;color: #333;">总收入</p>
			<span style="color: #999;">
			￥
			<fmt:formatNumber value="${incomeMoney}" pattern="#.##"
				minFractionDigits="2">
			</fmt:formatNumber>
			</span>
		</div>
		<div class="weui-cell__ft "
			style="font-size: 16px; padding-right: 25px">
			<p style="font-size: 16px;color: #333;">总支出</p>
			<span style="color: #999;">
			￥
			<fmt:formatNumber value="${expendMoney}" pattern="#.##"
				minFractionDigits="2">
			</fmt:formatNumber>
			</span>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function(){
	var checktime = 0;
	
	/* 记录列表是否点击 */
	$(".businessDetail").on("click",function(){
		var commercial=$(this).next().val();
		var incomeId=$(this).next().next().val();

		if(checktime==0 && commercial>0){
			 $(this).next().next().show(); 
			 checktime = 1;
		}else if(checktime == 1 && commercial>0){
			 $(this).next().next().hide();
			 checktime=0;
		}else if(commercial <=0){
			window.location.href="<c:url value='/wechat/acc/myWealth/income?id="+incomeId+"' />";
		}
		/*  $(this).next().toggle(300);  */
	});
});

$(".incomeMoney").each(function(){
	var money=$(this).text();
	$(this).text(money.substr(0,money.indexOf(".")+3))
});
</script>	
